package com.bootemp.common;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 可进行全局异常处理及模型属性加载
 */
//@ControllerAdvice
public class MyControl {
    @ExceptionHandler(Exception.class)
    public ResponseEntity<MyError> handleException(Exception ex){
        MyError error=new MyError(HttpStatus.INTERNAL_SERVER_ERROR.value(), "My Exception",ex.getMessage());
        return new ResponseEntity<>(error,HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
